import {
	request
} from "@/common/js/request.js";
const API = {
	/**
	 * 获取轮播图
	 * @param {Object} currentPage
	 * @param {Object} PageSize
	 */
	getSwiperImg(currentPage, PageSize) {
		return request({
			url: `/rotating/${currentPage}/${PageSize}`,
			method: 'GET'
		});
	},
	/**
	 * 获取推文
	 * @param {Object} currentPage
	 * @param {Object} PageSize
	 */
	getTweets(currentPage, PageSize) {
		return request({
			url: `/tweets/${currentPage}/${PageSize}`,
			method: 'GET'
		});
	},
	/**
	 * 获取维修者待处理订单
	 */
	getPending(token) {
		return request({
			url: '/repair/pending',
			method: 'POST',
			data: {
				"token": token
			}
		})
	},
	/**
	 * 获取维修者已接单
	 * @param {Object} token
	 */
	getAccept(token) {
		return request({
			url: '/repair/accept_info',
			method: 'POST',
			data: {
				"token": token
			}
		})
	},
	/**
	 * 获取维修者已完成
	 * @param {Object} token
	 */
	getFinish(token) {
		return request({
			url: '/repair/finish',
			method: 'POST',
			data: {
				"token": token
			}
		})
	},
	/**
	 * 获取维修者的订单
	 * @param {Object} token
	 */
	getMyRepair(token) {
		return request({
			url: '/repair/info_list',
			method: 'POST',
			data: {
				"token": token
			}
		})
	},
	/**
	 * 更新用户信息
	 * @param {Object} openid
	 * @param {Object} realname
	 * @param {Object} dormnum
	 * @param {Object} phone
	 * @param {Object} stunum
	 */
	UpdateUserInfo(token, realname, dormnum, phone, stunum) {
		return request({
			url: '/userinfo/info',
			method: 'POST',
			data: {
				"token": token,
				"realname": realname,
				"dormnum": dormnum,
				"phone": phone,
				"stunum": stunum
			}
		})
	},
	/**
	 * 创建维修订单
	 * @param {Object} r_openid
	 * @param {Object} r_pc_type
	 * @param {Object} r_pc_name
	 * @param {Object} r_reason
	 * @param {Object} r_img_list
	 */
	CreateRepairInfo(token, r_pc_type, r_pc_name, r_reason, r_img_list, r_reserve_time) {
		return request({
			url: '/repair/create',
			method: 'POST',
			data: {
				"token": token,
				"r_pc_type": r_pc_type,
				"r_pc_name": r_pc_name,
				"r_reason": r_reason,
				"r_img_list": r_img_list,
				"r_reserve_time": r_reserve_time
			}
		})
	},
	/**
	 * 维修人员接单
	 * @param {Object} r_id
	 * @param {Object} r_bm_openid
	 */
	AcceptRepair(r_id, token) {
		return request({
			url: "/repair/accept",
			method: 'POST',
			data: {
				"r_id": r_id,
				"token": token,
			}
		})
	},
	/**
	 * 获取用户维修订单
	 * @param {Object} r_openid
	 */
	getUserRepair(r_openid) {
		return request({
			url: "/repair/info_list",
			method: 'POST',
			data: {
				"r_openid": r_openid,
			}
		})
	},
	/**
	 * 获取特定的订单详情
	 * @param {Object} r_id
	 */
	getUserRepairInfo(r_id) {
		return request({
			url: "/repair/info",
			method: 'POST',
			data: {
				"r_id": r_id,
			}
		})
	},
	/**
	 * 获取用户信息
	 * @param {Object} token
	 */
	getUserInfo(token) {
		return request({
			url: '/userinfo/find',
			method: 'POST',
			data: {
				"token": token
			}
		})
	},
	/**
	 * 检查token是否有效
	 * @param {Object} token
	 */
	getTokenValid(token) {
		return request({
			url: '/user/token',
			method: 'POST',
			data: {
				"token": token
			}
		})
	},
	/**
	 * 删除上传图片
	 * @param {Object} url
	 */
	deleteImg(url) {
		return request({
			url: '/repair_img/delete',
			method: 'POST',
			data: {
				"r_img_url": url
			}
		})
	},
	/**
	 * 获取用户联系方式
	 * @param {Object} r_openid
	 */
	getUserPhone(r_openid) {
		return request({
			url: '/userinfo/openid',
			method: 'POST',
			data: {
				"r_openid": r_openid
			}
		})
	},
	UpdateRepairFinish(r_id, token) {
		return request({
			url: '/repair/finish_repair',
			method: 'POST',
			data: {
				"r_id": r_id,
				"token": token
			}
		})
	}
}

export default API;